<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
    <style>
        h4 {
            color: red;
        }
        div {
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
        #h2 {
            background-color: blue;
        }
        .error {
            background-color: red;

        }
        .success {
            background-color: green;

        }
        .msg {
            color: white;
        }
        #h2,.error,p {
            border: 1px solid plum;
        }
        * {
            font-style: italic;
        }
        [type="text"] {
            background-color: cyan;
        }
        #d1:hover {
            background-color: cyan;
        }
    /*  伪类选择器  */
        a:link {
            color : gray;
        }
        a:visited {
            color : green;
        }
        a:hover {
            color : orange;
        }
        a:active {
            color : red;
        }
        #d2 span {
            background-color: blue;
        }
        #d2>div>span {
            color: red;
        }
    </style>
</head>
    <body>
    <div id="d2">
        <span>1</span>
        <div>
            <span>2</span>
            <p>测试文字</p>
            <p>我是<span>测试</span>段落</p>
        </div>
        <span>3</span>
    </div>
    <br>







    <hr>
        <h4>我是标题</h4>
        <p>我是段落</p>
        <p>我是段落</p>
        <p>我是段落</p>
        <p>我是段落</p>
        <h4 id="h2">我是标题2</h4>
        <div id="d1">我是div</div>
        <div>我是div</div>
        <div>我是div</div>
        <div>我是div</div>
        <br>
        <span class="error msg">用户名不能为空</span>
        <span class="error msg">密码不能为空</span>
        <span class="success msg">用户名格式正确</span>
        <span class="success msg">密码格式正确</span>
        <br>
        <input type="text">
        <input type="password">
        <hr>
        <a href="https://www.baidu.com">超链接1</a>
        <a href="abc">超链接2</a>
    </body>
</html>